<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小米商城 - 小米11、Redmi Note 9、小米MIX Alpha，小米电视官方网站</title>
    <link rel="shortcut icon" href="images/favicon/favicon.ico" type="image/x-icon">
    <!-- 采用html , css , js 分开写的原则
    这里属于自己写的 css 部分 -->
    <link rel="stylesheet" href="/css/General style.css">
    <link rel="stylesheet" href="/css/header.css">
    <link rel="stylesheet" href="/css/iconfont.css">
    <link rel="stylesheet" href="/css/slideshow.css">
    <link rel="stylesheet" href="/css/home-hero.css">
    <link rel="stylesheet" href="/css/home-main.css">
    <link rel="stylesheet" href="/css/footer.css">
    <!-- 根据窗口大小动态的改变工具栏的样式，以及大小 -->
    <link rel="stylesheet" href="/css/subbar.css" media="all and (max-width:1499.99999px)">   <!-- 媒体查询1 -->
    <link rel="stylesheet" href="/css/subbar2.css" media="all and (min-width:1500px)">  <!-- 媒体查询2 -->
    <link rel="stylesheet" href="/layui/css/layui.css">
</head>

<body>
<!-- 采用html , css , js 分开写的原则
这里属于自己写的 html 部分 -->
<!-- 头部 -->
<div th:replace="header::top"></div>
<!-- home-main首页主体 -->
<div class="home-main">
    <div class="container w">
        <!-- 手机 -->
        <div class="home-mobile-box">
            <!-- 下 -->
            <div class="box-bd">
                <div class="row clearfix">
                    <div class="mobile-right2 fl">
                        <ul id="productList" class="brick-list2 clearfix">
                            <!--<li class="brick-item brick-item-m brick-item-m-2">
                                <a href="#">
                                    <div class="figure figure-img">
                                        <img src="images/sj-08.webp" alt="">
                                    </div>
                                    <h3 class="title">腾讯黑鲨3s</h3>
                                    <p class="desc">骁龙865处理器，120Hz刷新率</p>
                                    <p class="price">
                                        <span class="num">1599</span>元
                                        <span>起</span>
                                    </p>
                                </a>
                            </li>-->
                        </ul>
                    </div>
                </div>
                <div style="text-align: center" id="laypage"></div>
            </div>
        </div>
    </div>
</div>
<!-- 底部 -->
<div class="footer-box">
    <div class="site-footer clearfix">
        <div class="w">
            <!-- 服务部分 -->
            <div class="footer-service">
                <ul class="list-service clearfix">
                    <li><a href="#"><em class="iconfont">&#xe629;</em>预约维修服务</a></li>
                    <li><a href="#"><em class="iconfont">&#xe61f;</em>7天无理由退货</a></li>
                    <li><a href="#"><em class="iconfont iconfont-circle-15">&#xe606;</em>15天免费换货</a></li>
                    <li><a href="#"><em class="iconfont">&#xe633;</em>满99元包邮</a></li>
                    <li><a href="#"><em class="iconfont">&#xe632;</em>520余家售后网点</a></li>
                </ul>
            </div>
            <!-- 友情链接 -->
            <div class="footer-links">
                <dl class="col-links">
                    <dt>帮助中心</dt>
                    <dd><a href="#">账户管理</a></dd>
                    <dd><a href="#">购物指南</a></dd>
                    <dd><a href="#">订单操作</a></dd>
                </dl>
                <dl class="col-links">
                    <dt>服务支持</dt>
                    <dd><a href="#">售后政策</a></dd>
                    <dd><a href="#">自助服务</a></dd>
                    <dd><a href="#">相关下载</a></dd>
                </dl>
                <dl class="col-links">
                    <dt>线下门店</dt>
                    <dd><a href="#">小米之家</a></dd>
                    <dd><a href="#">服务网点</a></dd>
                    <dd><a href="#">授权体验店</a></dd>
                </dl>
                <dl class="col-links">
                    <dt>关于小米</dt>
                    <dd><a href="#">了解小米</a></dd>
                    <dd><a href="#">加入小米</a></dd>
                    <dd><a href="#">投资者关系</a></dd>
                    <dd><a href="#">企业社会责任</a></dd>
                    <dd><a href="#">廉洁举报</a></dd>
                </dl>
                <dl class="col-links">
                    <dt>关注我们</dt>
                    <dd><a href="#">新狼微博</a></dd>
                    <dd><a href="#">官方微信</a></dd>
                    <dd><a href="#">联系我们</a></dd>
                    <dd><a href="#">公益基金会</a></dd>
                </dl>
                <dl class="col-links">
                    <dt>特色服务</dt>
                    <dd><a href="#">F 码通道</a></dd>
                    <dd><a href="#">礼物码</a></dd>
                    <dd><a href="#">防伪查证</a></dd>
                </dl>
                <div class="col-contact">
                    <p class="phone">400-100-5678</p>
                    <p>8:00-18:00（仅收市话费）</p>
                    <a href="#" class="btn-small">
                        <em class="iconfont">&#xe604;</em> 人工客服
                    </a>
                    <div class="follow">
                        关注小米
                        <a href="#" class="wb"></a>
                        <a href="#" class="wx" id="J_followWx"></a>
                        <img src="images/wx-img.png" alt="" id="J_followWxImg">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="site-info">
        <div class="w container clearfix">
            <div class="logo ir">小米官网</div>
            <div class="info-text">
                <p class="sites">
                    <a href="#">小米商城</a>
                    <span>|</span>
                    <a href="#">MIUI</a>
                    <span>|</span>
                    <a href="#"> 米家</a>
                    <span>|</span>
                    <a href="#">米聊</a>
                    <span>|</span>
                    <a href="#">多看</a>
                    <span>|</span>
                    <a href="#">游戏</a>
                    <span>|</span>
                    <a href="#">政企服务</a>
                    <span>|</span>
                    <a href="#">小米天猫店</a>
                    <span>|</span>
                    <a href="#">小米集团隐私政策</a>
                    <span>|</span>
                    <a href="#">小米公司儿童信息保护规则</a>
                    <span>|</span>
                    <a href="#">小米商城隐私政策</a>
                    <span>|</span>
                    <a href="#">小米商城用户协议</a>
                    <span>|</span>
                    <a href="#">问题反馈</a>
                    <span>|</span>
                    <a href="#">Select Location</a>
                </p>
                <p class="sites">
                    <a href="#">北京互联网法院法律服务工作站</a>
                    <span>|</span>
                    <a href="#">中国消费者协会</a>
                    <span>|</span>
                    <a href="#">北京市消费者协会</a>
                </p>
                <p>
                    ©
                    <a href="#">mi.com</a> 京ICP证110507号
                    <a href="#">京ICP备10046444号</a>
                    <a href="#">京公网安备11010802020134号</a>
                    <a href="#">京网文[2020]0276-042号</a>
                    <br>
                    <a href="#">（京）网械平台备字（2018）第00005号</a>
                    <a href="#">互联网药品信息服务资格证 (京)-非经营性-2014-0090</a>
                    <a href="#">营业执照</a>
                    <a href="#">医疗器械质量公告</a>
                    <br>
                    <a href="#">增值电信业务许可证</a> 网络食品经营备案 京食药网食备202010048
                    <a href="#">食品经营许可证</a>
                    <br> 违法和不良信息举报电话：171-5104-4404
                    <a href="#">知识产权侵权投诉</a> 本网站所列数据，除特殊说明，所有数据均出自我司实验室测试
                </p>
            </div>
            <div class="info-links">
                <a href="#"><img src="images/truste.png" alt=""></a>
                <a href="#"><img src="images/v-logo-1.png" alt=""></a>
                <a href="#"><img src="images/v-logo-2.png" alt=""></a>
                <a href="#"><img src="images/fx.png" alt=""></a>
                <a href="#" class="safe-auth  J_safeAuth"><img src="images/js-1.png" alt="" class="img1"><img src="images/js-2.png" alt="" class="img2"></a>
            </div>
        </div>
        <div class="slogan">
            <a href="tencent://message/?Menu=yes&uin=2748826916&Service=300&sigT=45a1e5847943b64c6ff3990f8a9e644d2b31356cb0b4ac6b24663a3c8dd0f8aa12a595b1714f9d45">让全球每个人都能享受科技带来的美好生活</a>
        </div>
    </div>
</div>
<!-- 工具条 -->
<div class="home-tool-bar">
    <a href="#" class="item">
        <div class="icon">
            <img src="images/tool-1.png" alt="" class="static"><img src="images/tool-01.png" alt="" class="hover">
        </div>
        <span class="text">手机APP</span>
        <div class="pop-content">
            <img src="images/APP.png" alt="">
            <span class="desc">
                    扫码领取新人百元礼包
                </span>
        </div>
    </a>
    <a href="#" class="item">
        <div class="icon">
            <img src="images/tool-2.png" alt="" class="static"><img src="images/tool-02.png" alt="" class="hover">
        </div>
        <span class="text">个人中心</span>
    </a>
    <a href="#" class="item">
        <div class="icon">
            <img src="images/tool-3.png" alt="" class="static"><img src="images/tool-03.png" alt="" class="hover">
        </div>
        <span class="text">售后服务</span>
    </a>
    <a href="#" class="item">
        <div class="icon"><img src="images/tool-4.png" alt="" class="static"><img src="images/tool-04.png" alt="" class="hover"></div>
        <span class="text">人工客服</span>
    </a>
    <a href="./cart.html" class="item">
        <div class="icon"><img src="images/tool-5.png" alt="" class="static"><img src="images/tool-05.png" alt="" class="hover"></div>
        <span class="text">购物车</span>
    </a>
    <a href="#" class="item backtop" id="J_atop">
        <div class="icon">
            <img src="images/totop.png" alt="" class="static"><img src="images/totop_hover.png" alt="" class="hover">
        </div>
        <span class="text">回顶部</span>
    </a>
</div>
</body>

<!-- 采用html , css , js 分开写的原则
这里属于自己写的 js 部分 -->
<!-- 轮播图 -->
<script src="/js/slideshow.js "></script>
<!-- 轮播图动画 -->
<script src="/js/move.js "></script>
<!-- 移动 -->
<script src="/js/roll.js "></script>
<!-- 列表 -->
<script src="/js/tab.js"></script>
<!-- 逻辑上合理 使js html css 代码进行分离 这样可以改变数据得类型 -->
<script src="/jquery-2.1.4.js"></script>
<script src="/layui/layui.js"></script>
<script src="/mylayer.js"></script>
<!-- 主页 -->
<script src="/js/index.js"></script>
<!-- 逻辑上合理 使js html css 代码进行分离 这样可以改变数据得类型 -->
<script>
    /*$(function () {

    });*/
    layui.use(['laypage'], function () {
        var laypage = layui.laypage;

        var queryString = window.location.search;
        var urlParams = new URLSearchParams(queryString);
        var categoryId = urlParams.get("id");
        var name = urlParams.get("name");

        var page = 1; //当前是第几页
        var limit = 5; //设置一页显示多少数据
        var isFirst = true;
        loadData();

        function loadData() {
            $.post(
                '/product/list',
                {'page': page, 'limit': limit,'categoryId': categoryId,'name':name},
                function (result) {
                    console.log(result);
                    if (result.code == 0) {
                        if (isFirst) {
                            isFirst = false;
                            laypage.render({
                                elem: 'laypage',
                                count: result.count, // 数据总数
                                limit: 5, //每页显示的条数
                                limits: [5, 10, 15], //每页条数的选择项
                                layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
                                jump: function(obj, first){
                                    console.log(obj.curr); // 得到当前页，以便向服务端请求对应页的数据。
                                    console.log(obj.limit); // 得到每页显示的条数
                                    page = obj.curr;
                                    limit = obj.limit;
                                    // 首次不执行
                                    if(!first){
                                        loadData();
                                    }
                                }
                            });
                        }

                        $('#productList').empty();
                        $(result.data).each(function () {
                            var html = '';
                            html+='<li class="brick-item brick-item-m brick-item-m-2">'
                            html+='    <a href="/page/product/detail?id='+this.id+'">'
                            html+='        <div class="figure figure-img">'
                            html+='            <img src="'+this.mainImage+'" alt="">'
                            html+='        </div>'
                            html+='        <h3 class="title">'+this.name+'</h3>'
                            html+='        <p class="desc">'+this.subtitle+'</p>'
                            html+='        <p class="price">'
                            html+='            <span class="num">'+this.price+'</span>元'
                            html+='            <span>起</span>'
                            html+='        </p>'
                            html+='    </a>'
                            html+='</li>'
                            $('#productList').append(html);
                        });
                    }

                },
                'json'
            )
        }


    });

</script>
</html>